Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

include/FLAC++/encoder.h

Go to the documentation of this file.
00001 /* libFLAC++ - Free Lossless Audio Codec library
00002  * Copyright (C) 2002,2003  Josh Coalson
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef FLACPP__ENCODER_H
00021 #define FLACPP__ENCODER_H
00022 
00023 #include "export.h"
00024 
00025 #include "FLAC/file_encoder.h"
00026 #include "FLAC/seekable_stream_encoder.h"
00027 #include "FLAC/stream_encoder.h"
00028 #include "decoder.h"
00029 
00030 
00058 namespace FLAC {
00059     namespace Encoder {
00060 
00061         // ============================================================
00062         //
00063         //  Equivalent: FLAC__StreamEncoder
00064         //
00065         // ============================================================
00066 
00080         class FLACPP_API Stream {
00081         public:
00082             class FLACPP_API State {
00083             public:
00084                 inline State(::FLAC__StreamEncoderState state): state_(state) { }
00085                 inline operator ::FLAC__StreamEncoderState() const { return state_; }
00086                 inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
00087                 const char *resolved_as_cstring(const Stream &) const;
00088             protected:
00089                 ::FLAC__StreamEncoderState state_;
00090             };
00091 
00092             Stream();
00093             virtual ~Stream();
00094 
00095             bool is_valid() const;
00096             inline operator bool() const { return is_valid(); }
00097 
00098             bool set_verify(bool value);
00099             bool set_streamable_subset(bool value);
00100             bool set_do_mid_side_stereo(bool value);
00101             bool set_loose_mid_side_stereo(bool value);
00102             bool set_channels(unsigned value);
00103             bool set_bits_per_sample(unsigned value);
00104             bool set_sample_rate(unsigned value);
00105             bool set_blocksize(unsigned value);
00106             bool set_max_lpc_order(unsigned value);
00107             bool set_qlp_coeff_precision(unsigned value);
00108             bool set_do_qlp_coeff_prec_search(bool value);
00109             bool set_do_escape_coding(bool value);
00110             bool set_do_exhaustive_model_search(bool value);
00111             bool set_min_residual_partition_order(unsigned value);
00112             bool set_max_residual_partition_order(unsigned value);
00113             bool set_rice_parameter_search_dist(unsigned value);
00114             bool set_total_samples_estimate(FLAC__uint64 value);
00115             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00116 
00117             State    get_state() const;
00118             Decoder::Stream::State get_verify_decoder_state() const;
00119             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00120             bool     get_verify() const;
00121             bool     get_streamable_subset() const;
00122             bool     get_do_mid_side_stereo() const;
00123             bool     get_loose_mid_side_stereo() const;
00124             unsigned get_channels() const;
00125             unsigned get_bits_per_sample() const;
00126             unsigned get_sample_rate() const;
00127             unsigned get_blocksize() const;
00128             unsigned get_max_lpc_order() const;
00129             unsigned get_qlp_coeff_precision() const;
00130             bool     get_do_qlp_coeff_prec_search() const;
00131             bool     get_do_escape_coding() const;
00132             bool     get_do_exhaustive_model_search() const;
00133             unsigned get_min_residual_partition_order() const;
00134             unsigned get_max_residual_partition_order() const;
00135             unsigned get_rice_parameter_search_dist() const;
00136             FLAC__uint64 get_total_samples_estimate() const;
00137 
00138             State init();
00139 
00140             void finish();
00141 
00142             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00143             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00144         protected:
00145             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00146             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00147 
00148             ::FLAC__StreamEncoder *encoder_;
00149         private:
00150             static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00151             static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00152 
00153             // Private and undefined so you can't use them:
00154             Stream(const Stream &);
00155             void operator=(const Stream &);
00156         };
00157 
00158         /* \} */
00159 
00173         class FLACPP_API SeekableStream {
00174         public:
00175             class FLACPP_API State {
00176             public:
00177                 inline State(::FLAC__SeekableStreamEncoderState state): state_(state) { }
00178                 inline operator ::FLAC__SeekableStreamEncoderState() const { return state_; }
00179                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamEncoderStateString[state_]; }
00180                 const char *resolved_as_cstring(const SeekableStream &) const;
00181             protected:
00182                 ::FLAC__SeekableStreamEncoderState state_;
00183             };
00184 
00185             SeekableStream();
00186             virtual ~SeekableStream();
00187 
00188             bool is_valid() const;
00189             inline operator bool() const { return is_valid(); }
00190 
00191             bool set_verify(bool value);
00192             bool set_streamable_subset(bool value);
00193             bool set_do_mid_side_stereo(bool value);
00194             bool set_loose_mid_side_stereo(bool value);
00195             bool set_channels(unsigned value);
00196             bool set_bits_per_sample(unsigned value);
00197             bool set_sample_rate(unsigned value);
00198             bool set_blocksize(unsigned value);
00199             bool set_max_lpc_order(unsigned value);
00200             bool set_qlp_coeff_precision(unsigned value);
00201             bool set_do_qlp_coeff_prec_search(bool value);
00202             bool set_do_escape_coding(bool value);
00203             bool set_do_exhaustive_model_search(bool value);
00204             bool set_min_residual_partition_order(unsigned value);
00205             bool set_max_residual_partition_order(unsigned value);
00206             bool set_rice_parameter_search_dist(unsigned value);
00207             bool set_total_samples_estimate(FLAC__uint64 value);
00208             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00209 
00210             State    get_state() const;
00211             Stream::State get_stream_encoder_state() const;
00212             Decoder::Stream::State get_verify_decoder_state() const;
00213             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00214             bool     get_verify() const;
00215             bool     get_streamable_subset() const;
00216             bool     get_do_mid_side_stereo() const;
00217             bool     get_loose_mid_side_stereo() const;
00218             unsigned get_channels() const;
00219             unsigned get_bits_per_sample() const;
00220             unsigned get_sample_rate() const;
00221             unsigned get_blocksize() const;
00222             unsigned get_max_lpc_order() const;
00223             unsigned get_qlp_coeff_precision() const;
00224             bool     get_do_qlp_coeff_prec_search() const;
00225             bool     get_do_escape_coding() const;
00226             bool     get_do_exhaustive_model_search() const;
00227             unsigned get_min_residual_partition_order() const;
00228             unsigned get_max_residual_partition_order() const;
00229             unsigned get_rice_parameter_search_dist() const;
00230             FLAC__uint64 get_total_samples_estimate() const;
00231 
00232             State init();
00233 
00234             void finish();
00235 
00236             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00237             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00238         protected:
00239             virtual ::FLAC__SeekableStreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00240             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00241 
00242             ::FLAC__SeekableStreamEncoder *encoder_;
00243         private:
00244             static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00245             static ::FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00246 
00247             // Private and undefined so you can't use them:
00248             SeekableStream(const SeekableStream &);
00249             void operator=(const SeekableStream &);
00250         };
00251 
00252         /* \} */
00253 
00267         class FLACPP_API File {
00268         public:
00269             class FLACPP_API State {
00270             public:
00271                 inline State(::FLAC__FileEncoderState state): state_(state) { }
00272                 inline operator ::FLAC__FileEncoderState() const { return state_; }
00273                 inline const char *as_cstring() const { return ::FLAC__FileEncoderStateString[state_]; }
00274                 const char *resolved_as_cstring(const File &) const;
00275             protected:
00276                 ::FLAC__FileEncoderState state_;
00277             };
00278 
00279             File();
00280             virtual ~File();
00281 
00282             bool is_valid() const;
00283             inline operator bool() const { return is_valid(); }
00284 
00285             bool set_verify(bool value);
00286             bool set_streamable_subset(bool value);
00287             bool set_do_mid_side_stereo(bool value);
00288             bool set_loose_mid_side_stereo(bool value);
00289             bool set_channels(unsigned value);
00290             bool set_bits_per_sample(unsigned value);
00291             bool set_sample_rate(unsigned value);
00292             bool set_blocksize(unsigned value);
00293             bool set_max_lpc_order(unsigned value);
00294             bool set_qlp_coeff_precision(unsigned value);
00295             bool set_do_qlp_coeff_prec_search(bool value);
00296             bool set_do_escape_coding(bool value);
00297             bool set_do_exhaustive_model_search(bool value);
00298             bool set_min_residual_partition_order(unsigned value);
00299             bool set_max_residual_partition_order(unsigned value);
00300             bool set_rice_parameter_search_dist(unsigned value);
00301             bool set_total_samples_estimate(FLAC__uint64 value);
00302             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00303             bool set_filename(const char *value);
00304 
00305             State    get_state() const;
00306             SeekableStream::State get_seekable_stream_encoder_state() const;
00307             Stream::State get_stream_encoder_state() const;
00308             Decoder::Stream::State get_verify_decoder_state() const;
00309             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00310             bool     get_verify() const;
00311             bool     get_streamable_subset() const;
00312             bool     get_do_mid_side_stereo() const;
00313             bool     get_loose_mid_side_stereo() const;
00314             unsigned get_channels() const;
00315             unsigned get_bits_per_sample() const;
00316             unsigned get_sample_rate() const;
00317             unsigned get_blocksize() const;
00318             unsigned get_max_lpc_order() const;
00319             unsigned get_qlp_coeff_precision() const;
00320             bool     get_do_qlp_coeff_prec_search() const;
00321             bool     get_do_escape_coding() const;
00322             bool     get_do_exhaustive_model_search() const;
00323             unsigned get_min_residual_partition_order() const;
00324             unsigned get_max_residual_partition_order() const;
00325             unsigned get_rice_parameter_search_dist() const;
00326             FLAC__uint64 get_total_samples_estimate() const;
00327 
00328             State init();
00329 
00330             void finish();
00331 
00332             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00333             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00334         protected:
00335             virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
00336 
00337             ::FLAC__FileEncoder *encoder_;
00338         private:
00339             static void progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
00340 
00341             // Private and undefined so you can't use them:
00342             File(const Stream &);
00343             void operator=(const Stream &);
00344         };
00345 
00346         /* \} */
00347 
00348     };
00349 };
00350 
00351 #endif

Generated on Sat Jan 25 10:44:46 2003 for FLAC by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002